"use strict";
var React = require('react');
var ReactDOM = require('react-dom');

class Counter extends React.Component {
    constructor(props) {
        super(props);
        this.state = {count: 0};
    }

    tick() {
        this.setState({count: this.state.count + 1});
    }

    render() {
        return (
            <div className="text-center">
                <h1>
                    Clicks: {this.state.count}
                </h1>
                <button className="btn btn-info" onClick={this.tick.bind(this)}>加1</button>
            </div>


        )
    }
}


ReactDOM.render(<Counter />, document.getElementById('app'))


已注销
981 声望48 粉丝

Focus on programming efficiency